package com.qiulingcloud.order.service.feign.fallback;

import com.qiulingcloud.commonsserver.entity.SysUser;
import com.qiulingcloud.commonsserver.exception.code.BaseResponseCode;
import com.qiulingcloud.order.service.feign.FeignUserService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author：zhangqiang
 * @Description：
 * @Date：Created in 20:52 2020/5/8
 * @Modified By：
 */
@Service
@Slf4j
public class FeignUserServiceFallback implements FallbackFactory<FeignUserService> {

    @Override
    public FeignUserService create(Throwable throwable) {
        log.error("{}", throwable);
        return new FeignUserService() {
            @Override
            public SysUser gerUserByUserId(String userId) {
                SysUser user = new SysUser();
                user.setId(String.valueOf(BaseResponseCode.ERROR.getCode()));
                return user;
            }
        };
    }
}
